package com.bc.web.service;


import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import org.jxls.common.Context;

import com.bc.web.config.R;
import com.bc.web.config.SystemEnum;
import com.bc.web.model.Account;
import com.bc.web.model.ClearingCollect;
import com.bc.web.model.ClearingDetail;
import com.bc.web.model.Dictionary;
import com.bc.web.model.Merch;
import com.bc.web.model.TradeOrder;
import com.fs.common.util.FSDate;
import com.fs.common.util.FSExcel;
import com.fs.common.util.FSJedis;
import com.fs.common.util.FSLog;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class ReportService {
	private static final String REPORT_PATH = SystemEnum.FilePath.ReportTmp.getValue();
	private static final String TEMPLATE = SystemEnum.FilePath.ReportTemplate.getValue();
	private static Map<String, String> merchMap = new HashMap<String, String>(1024);
	private static Map<String, String> payTypeMap = new HashMap<String, String>(64);
	private static Map<String, String> compareStatusMap = new HashMap<String, String>();
	private static Map<String, String> paymentStatusMap = new HashMap<String, String>();
	
	static {
		List<Merch> merchList = Merch.dao.selectToRedis();
		if (merchList.size() > 0) {
			for (Merch m : merchList) {
				merchMap.put(m.getCode(), m.getName());
			}
		}

		List<Dictionary> dList = Dictionary.dao.selectPayType();
		if (dList.size() > 0) {
			for (Dictionary d : dList) {
				payTypeMap.put(d.getCode(), d.getName());
			}
		}

		compareStatusMap.put(SystemEnum.CompareStatus.Init.getValue(), "初始");
		compareStatusMap.put(SystemEnum.CompareStatus.LocalError.getValue(), "汇卡差错");
		compareStatusMap.put(SystemEnum.CompareStatus.ChannelError.getValue(), "渠道差错");
		compareStatusMap.put(SystemEnum.CompareStatus.LocalErrorSuccess.getValue(), "汇卡差错成功");
		compareStatusMap.put(SystemEnum.CompareStatus.ChannelErrorSuccess.getValue(), "渠道差错成功");
		compareStatusMap.put(SystemEnum.CompareStatus.Success.getValue(), "成功");

		paymentStatusMap.put(SystemEnum.PaymentStatus.Init.getValue(), "初始");
		paymentStatusMap.put(SystemEnum.PaymentStatus.Freeze.getValue(), "冻结");
		paymentStatusMap.put(SystemEnum.PaymentStatus.Thaw.getValue(), "解冻");
		paymentStatusMap.put(SystemEnum.PaymentStatus.Unknown.getValue(), "待确定");
		paymentStatusMap.put(SystemEnum.PaymentStatus.Fail.getValue(), "失败");
		paymentStatusMap.put(SystemEnum.PaymentStatus.Success.getValue(), "成功");

	}

	/**
	 * 汇卡交易明细报表
	 * 
	 * @param settleDateStart
	 * @param settleDateEnd
	 * @return
	 */
	public File hicardDetail(String settleDateStart, String settleDateEnd) {
		Object[] compareStatus = { SystemEnum.CompareStatus.Init.getValue(), SystemEnum.CompareStatus.Success.getValue(),
				SystemEnum.CompareStatus.LocalError.getValue(), SystemEnum.CompareStatus.LocalErrorSuccess.getValue() };
		List<ClearingDetail> detailList = ClearingDetail.dao.selectByCompareStatus(settleDateStart, settleDateEnd,
				compareStatus);
		if (detailList.isEmpty()) {
			//HCLog.web.info("没有满足条件的汇卡交易数据");
			return null;
		}

		List<ClearingDetail> dataList = new ArrayList<>(detailList.size());
		for (ClearingDetail c : detailList) {
			String merchName = merchMap.get(c.getMerchCode());
			if (StrKit.isBlank(merchName)) {
				Merch m = FSJedis.get(R.RK_MERCH, c.getMerchCode(), Merch.class);
				if (m != null) {
					merchName = m.getName();
					merchMap.put(m.getCode(), m.getName());
				}
			}
			c.put("merchName", merchName);
			c.setCompareStatus(compareStatusMap.get(c.getCompareStatus()));
			c.setPayTypeCode(payTypeMap.get(c.getPayTypeCode()));
			dataList.add(c);
		}

		String createTime = FSDate.getDateTime();
		String condition = "日切日期[" + settleDateStart + "至" + settleDateEnd + "]";
		String fileName = "汇卡交易报表_" + settleDateStart + "至" + settleDateEnd;

		Context context = new Context();
		context.putVar("createTime", createTime);
		context.putVar("condition", condition);
		context.putVar("list", dataList);

		String templatePath = TEMPLATE + "hicard_detail.xlsx";
		String targetPath = REPORT_PATH + fileName + ".xlsx";
		LinkedHashMap<String, Context> sheetNameAndData = new LinkedHashMap<>();
		sheetNameAndData.put("汇卡交易明细", context);
		String[] templateSheetName = { "sheet1" };

		try {
			FSExcel.exportLargeData(templatePath, targetPath, sheetNameAndData, templateSheetName);
		} catch (Exception e) {
			//HCLog.web.info("导出汇卡交易明细报表发生异常" + e);
		}
		File file = new File(targetPath);
		return file;
	}

	/**
	 * 渠道交易明细报表
	 * 
	 * @param settleDateStart
	 * @param settleDateEnd
	 * @return
	 */
	public File channelDetail(String settleDateStart, String settleDateEnd) {
		Object[] compareStatus = { SystemEnum.CompareStatus.Success.getValue(),
				SystemEnum.CompareStatus.ChannelError.getValue(),
				SystemEnum.CompareStatus.ChannelErrorSuccess.getValue() };
		List<ClearingDetail> detailList = ClearingDetail.dao.selectByCompareStatus(settleDateStart, settleDateEnd,
				compareStatus);
		if (detailList.isEmpty()) {
			//.web.info("没有满足条件的渠道交易数据");
			return null;
		}

		List<ClearingDetail> dataList = new ArrayList<>(detailList.size());
		for (ClearingDetail c : detailList) {
			String merchName = merchMap.get(c.getMerchCode());
			if (StrKit.isBlank(merchName)) {
				Merch m = FSJedis.get(R.RK_MERCH, c.getMerchCode(), Merch.class);
				if (m != null) {
					merchName = m.getName();
					merchMap.put(m.getCode(), m.getName());
				}
			}
			c.put("merchName", merchName);
			c.setCompareStatus(compareStatusMap.get(c.getCompareStatus()));
			c.setPayTypeCode(payTypeMap.get(c.getPayTypeCode()));
			dataList.add(c);
		}

		String createTime = FSDate.getDateTime();
		String condition = "日切日期[" + settleDateStart + "至" + settleDateEnd + "]";
		String fileName = "渠道交易报表_" + settleDateStart + "至" + settleDateEnd;

		Context context = new Context();
		context.putVar("createTime", createTime);
		context.putVar("condition", condition);
		context.putVar("list", dataList);

		String templatePath = TEMPLATE + "channel_detail.xlsx";
		String targetPath = REPORT_PATH + fileName + ".xlsx";
		LinkedHashMap<String, Context> sheetNameAndData = new LinkedHashMap<>();
		sheetNameAndData.put("渠道交易明细", context);
		String[] templateSheetName = { "sheet1" };

		try {
			FSExcel.exportLargeData(templatePath, targetPath, sheetNameAndData, templateSheetName);
		} catch (Exception e) {
			//.web.info("导出渠道交易明细报表发生异常" + e);
		}
		File file = new File(targetPath);
		return file;
	}

	/**
	 * 差错报表
	 * 
	 * @param settleDateStart
	 * @param settleDateEnd
	 * @return
	 */
	public File error(String settleDateStart, String settleDateEnd) {
		Object[] compareStatus1 = { SystemEnum.CompareStatus.LocalError.getValue(),
				SystemEnum.CompareStatus.LocalErrorSuccess.getValue() };
		Object[] compareStatus2 = { SystemEnum.CompareStatus.ChannelError.getValue(),
				SystemEnum.CompareStatus.ChannelErrorSuccess.getValue() };
		List<ClearingDetail> detailList1 = ClearingDetail.dao.selectByCompareStatus(settleDateStart, settleDateEnd,
				compareStatus1);
		List<ClearingDetail> detailList2 = ClearingDetail.dao.selectByCompareStatus(settleDateStart, settleDateEnd,
				compareStatus2);
		if (detailList1.isEmpty() && detailList2.isEmpty()) {
			//.web.info("没有满足条件的差错数据");
			return null;
		}
		List<ClearingDetail> dataList1 = new ArrayList<>(detailList1.size());
		for (ClearingDetail c : detailList1) {
			String merchName = merchMap.get(c.getMerchCode());
			if (StrKit.isBlank(merchName)) {
				Merch m = FSJedis.get(R.RK_MERCH, c.getMerchCode(), Merch.class);
				if (m != null) {
					merchName = m.getName();
					merchMap.put(m.getCode(), m.getName());
				}
			}
			c.put("merchName", merchName);
			c.setCompareStatus(compareStatusMap.get(c.getCompareStatus()));
			c.setPayTypeCode(payTypeMap.get(c.getPayTypeCode()));
			dataList1.add(c);
		}

		List<ClearingDetail> dataList2 = new ArrayList<>(detailList2.size());
		for (ClearingDetail c : detailList2) {
			String merchName = merchMap.get(c.getMerchCode());
			if (StrKit.isBlank(merchName)) {
				Merch m = FSJedis.get(R.RK_MERCH, c.getMerchCode(), Merch.class);
				if (m != null) {
					merchName = m.getName();
					merchMap.put(m.getCode(), m.getName());
				}
			}
			c.put("merchName", merchName);
			c.setCompareStatus(compareStatusMap.get(c.getCompareStatus()));
			c.setPayTypeCode(payTypeMap.get(c.getPayTypeCode()));
			dataList2.add(c);
		}

		String createTime = FSDate.getDateTime();
		String condition = "日切日期[" + settleDateStart + "至" + settleDateEnd + "]";
		String fileName = "差错报表_" + settleDateStart + "至" + settleDateEnd;

		Context context1 = new Context();
		context1.putVar("createTime", createTime);
		context1.putVar("condition", condition);
		context1.putVar("list", dataList1);

		Context context2 = new Context();
		context2.putVar("createTime", createTime);
		context2.putVar("condition", condition);
		context2.putVar("list", dataList2);

		String templatePath = TEMPLATE + "error.xlsx";
		String targetPath = REPORT_PATH + fileName + ".xlsx";
		LinkedHashMap<String, Context> sheetNameAndData = new LinkedHashMap<>();
		sheetNameAndData.put("汇卡差错", context1);
		sheetNameAndData.put("渠道差错", context2);
		String[] templateSheetName = { "sheet1", "sheet2" };

		try {
			FSExcel.exportLargeData(templatePath, targetPath, sheetNameAndData, templateSheetName);
		} catch (Exception e) {
			//.web.info("导出差错报表发生异常" + e);
		}
		File file = new File(targetPath);
		return file;
	}

	/**
	 * 出账明细报表
	 * 
	 * @param settleDateStart
	 * @param settleDateEnd
	 * @return
	 */
	public File paymentDetail(String settleDateStart, String settleDateEnd) {
		Object[] compareStatus = { SystemEnum.CompareStatus.Success.getValue(),
				SystemEnum.CompareStatus.LocalErrorSuccess.getValue(),
				SystemEnum.CompareStatus.ChannelErrorSuccess.getValue() };
		List<ClearingDetail> detailList = ClearingDetail.dao.selectByCompareStatus(settleDateStart, settleDateEnd,
				compareStatus);
		if (detailList.isEmpty()) {
			//HCLog.web.info("没有满足条件的出账明细数据");
			return null;
		}

		List<ClearingDetail> dataList = new ArrayList<>(detailList.size());
		for (ClearingDetail c : detailList) {
			String merchName = merchMap.get(c.getMerchCode());
			if (StrKit.isBlank(merchName)) {
				Merch m = FSJedis.get(R.RK_MERCH, c.getMerchCode(), Merch.class);
				if (m != null) {
					merchName = m.getName();
					merchMap.put(m.getCode(), m.getName());
				}
			}
			c.put("merchName", merchName);
			c.setPaymentStatus(paymentStatusMap.get(c.getPaymentStatus()));
			c.setPayTypeCode(payTypeMap.get(c.getPayTypeCode()));
			dataList.add(c);
		}

		String createTime = FSDate.getDateTime();
		String condition = "日切日期[" + settleDateStart + "至" + settleDateEnd + "]";
		String fileName = "出账明细报表_" + settleDateStart + "至" + settleDateEnd;

		Context context = new Context();
		context.putVar("createTime", createTime);
		context.putVar("condition", condition);
		context.putVar("list", dataList);

		String templatePath = TEMPLATE + "payment_detail.xlsx";
		String targetPath = REPORT_PATH + fileName + ".xlsx";
		LinkedHashMap<String, Context> sheetNameAndData = new LinkedHashMap<>();
		sheetNameAndData.put("出账明细", context);
		String[] templateSheetName = { "sheet1" };

		try {
			FSExcel.exportLargeData(templatePath, targetPath, sheetNameAndData, templateSheetName);
		} catch (Exception e) {
			//HCLog.web.info("导出出账明细报表发生异常" + e);
		}
		File file = new File(targetPath);
		return file;
	}

	/**
	 * 风控报表
	 * 
	 * @param settleDateStart
	 * @param settleDateEnd
	 * @return
	 */
	public File risk(String settleDateStart, String settleDateEnd) {
		Object[] paymentStatus = { SystemEnum.PaymentStatus.Success.getValue(),
				SystemEnum.PaymentStatus.Unknown.getValue(), SystemEnum.PaymentStatus.Fail.getValue(),
				SystemEnum.PaymentStatus.Freeze.getValue(), SystemEnum.PaymentStatus.Thaw.getValue() };
		Object[] isRisk = { true };
		List<ClearingDetail> detailList = ClearingDetail.dao.selectByPaymentStatus(settleDateStart, settleDateEnd,
				paymentStatus, isRisk);
		List<ClearingCollect> collectList = ClearingCollect.dao.selectReportData(settleDateStart, settleDateEnd,
				paymentStatus, isRisk);
		if (detailList.isEmpty() && collectList.isEmpty()) {
			//HCLog.web.info("没有满足条件的风控数据");
			return null;
		}
		List<ClearingDetail> dataList1 = new ArrayList<>(detailList.size());
		for (ClearingDetail c : detailList) {
			String merchName = merchMap.get(c.getMerchCode());
			if (StrKit.isBlank(merchName)) {
				Merch m = FSJedis.get(R.RK_MERCH, c.getMerchCode(), Merch.class);
				if (m != null) {
					merchName = m.getName();
					merchMap.put(m.getCode(), m.getName());
				}
			}
			c.put("merchName", merchName);
			c.setPaymentStatus(paymentStatusMap.get(c.getPaymentStatus()));
			c.setPayTypeCode(payTypeMap.get(c.getPayTypeCode()));
			dataList1.add(c);
		}
		List<ClearingCollect> dataList2 = new ArrayList<>(collectList.size());
		for (ClearingCollect c : collectList) {
			String merchName = merchMap.get(c.getMerchCode());
			if (StrKit.isBlank(merchName)) {
				Merch m = FSJedis.get(R.RK_MERCH, c.getMerchCode(), Merch.class);
				if (m != null) {
					merchName = m.getName();
					merchMap.put(m.getCode(), m.getName());
				}
			}
			c.put("merchName", merchName);
			c.setPaymentStatus(paymentStatusMap.get(c.getPaymentStatus()));
			dataList2.add(c);
		}

		String createTime = FSDate.getDateTime();
		String condition = "日切日期[" + settleDateStart + "至" + settleDateEnd + "]";
		String fileName = "风控报表_" + settleDateStart + "至" + settleDateEnd;

		Context context1 = new Context();
		context1.putVar("createTime", createTime);
		context1.putVar("condition", condition);
		context1.putVar("list", detailList);

		Context context2 = new Context();
		context2.putVar("createTime", createTime);
		context2.putVar("condition", condition);
		context2.putVar("list", collectList);

		String templatePath = TEMPLATE + "risk.xlsx";
		String targetPath = REPORT_PATH + fileName + ".xlsx";
		LinkedHashMap<String, Context> sheetNameAndData = new LinkedHashMap<>();
		sheetNameAndData.put("明细风控", context1);
		sheetNameAndData.put("结果风控", context2);
		String[] templateSheetName = { "sheet1", "sheet2" };

		try {
			FSExcel.exportLargeData(templatePath, targetPath, sheetNameAndData, templateSheetName);
		} catch (Exception e) {
			//HCLog.web.info("导出风控报表发生异常" + e);
		}
		File file = new File(targetPath);
		return file;
	}

	/**
	 * 出账结果报表
	 * 
	 * @param settleDateStart
	 * @param settleDateEnd
	 * @return
	 */
	public File paymentCollect(String settleDateStart, String settleDateEnd) {
		Object[] paymentStatus = { SystemEnum.PaymentStatus.Success.getValue(),
				SystemEnum.PaymentStatus.Unknown.getValue(), SystemEnum.PaymentStatus.Fail.getValue() };
		Object[] isRisk = { true, false };
		List<ClearingCollect> collectList = ClearingCollect.dao.selectReportData(settleDateStart, settleDateEnd,
				paymentStatus, isRisk);
		if (collectList.isEmpty()) {
			//HCLog.web.info("没有满足条件的出账结果数据");
			return null;
		}
		List<ClearingCollect> dataList = new ArrayList<>(collectList.size());
		for (ClearingCollect c : collectList) {
			String merchName = merchMap.get(c.getMerchCode());
			if (StrKit.isBlank(merchName)) {
				Merch m = FSJedis.get(R.RK_MERCH, c.getMerchCode(), Merch.class);
				if (m != null) {
					merchName = m.getName();
					merchMap.put(m.getCode(), m.getName());
				}
			}
			c.put("merchName", merchName);
			c.setPaymentStatus(paymentStatusMap.get(c.getPaymentStatus()));
			dataList.add(c);
		}

		String createTime = FSDate.getDateTime();
		String condition = "记账日期[" + settleDateStart + "至" + settleDateEnd + "]";
		String fileName = "出账结果报表_" + settleDateStart + "至" + settleDateEnd;

		Context context = new Context();
		context.putVar("createTime", createTime);
		context.putVar("condition", condition);
		context.putVar("list", dataList);

		String templatePath = TEMPLATE + "payment_collect.xlsx";
		String targetPath = REPORT_PATH + fileName + ".xlsx";
		LinkedHashMap<String, Context> sheetNameAndData = new LinkedHashMap<>();
		sheetNameAndData.put("出账结果", context);
		String[] templateSheetName = { "sheet1" };

		try {
			FSExcel.exportLargeData(templatePath, targetPath, sheetNameAndData, templateSheetName);
		} catch (Exception e) {
			//HCLog.web.info("导出出账结果报表发生异常" + e);
		}
		File file = new File(targetPath);
		return file;
	}
	
	/**
	 * 虚账余额报表
	 * 
	 * @return
	 */
	public File virtualBalance() {
		List<Record> dataList = Db.use(R.BD_TRADE).find("SELECT channelNo, SUM(balance) AS balance FROM account GROUP BY channelNo");
		List<Account> channelIncome = Account.dao.find("SELECT * FROM account WHERE accountNo='C00000000000001'");
		List<Account> dataList2 = Account.dao.find("SELECT * FROM account WHERE balance > 0 ORDER BY channelNo,balance DESC");
		if (dataList.isEmpty() || dataList2.isEmpty()) {
			FSLog.web.info("无数据");
			return null;
		}
		List<Record> balanceSumList = new ArrayList<>();
		for (Record r : dataList) {
			for (Account a : channelIncome) {
				if(Objects.equals(r.get("channelNo"), a.getChannelNo())) {
					r.set("income", a.getBalance());
				}
			}
			balanceSumList.add(r);
		}

		Context context1 = new Context();
		context1.putVar("list", balanceSumList);
		
		Context context2 = new Context();
		context2.putVar("list2", dataList2);

		String createTime = FSDate.getDateTimeNumber();
		String templatePath = TEMPLATE + "virtual_balance.xlsx";
		String targetPath = REPORT_PATH + "虚账余额" + createTime + ".xlsx";
		LinkedHashMap<String, Context> sheetNameAndData = new LinkedHashMap<>();
		sheetNameAndData.put("虚账余额渠道汇总", context1);
		sheetNameAndData.put("虚账余额明细", context2);
		String[] templateSheetName = {"sheet1", "sheet2"};

		try {
			FSExcel.exportLargeData(templatePath, targetPath, sheetNameAndData, templateSheetName);
		} catch (Exception e) {
			FSLog.web.info("导出虚账余额报表发生异常" + e);
		}
		File file = new File(targetPath);
		return file;
	}
	
	/**
	 * 本地交易明细报表
	 * 
	 * @param settleDateStart
	 * @param settleDateEnd
	 * @return
	 */
	public File localDetail(String merchCode, String settleDateStart, String settleDateEnd) {
		List<TradeOrder> detailList = TradeOrder.dao.searchReportForMerch(merchCode, settleDateStart, settleDateEnd);
		if (detailList.isEmpty()) {
			//HCLog.web.info("没有满足条件的本地交易数据");
			return null;
		}
		DecimalFormat df = new DecimalFormat("0.00");
		List<TradeOrder> dataList = new ArrayList<>(detailList.size());
		for (TradeOrder c : detailList) {
			String merchName = merchMap.get(c.getMerchCode());
			if (StrKit.isBlank(merchName)) {
				Merch m = Merch.dao.selectByMerchCode(c.getMerchCode());
				if (m != null) {
					merchName = m.getName();
					merchMap.put(m.getCode(), m.getName());
				}
			}
			c.put("merchName", merchName);
			c.setPayType(payTypeMap.get(c.getPayType()));
			c.put("amountY", df.format(c.getAmount()/100.0));
			c.put("merchFeeY",df.format(c.getMerchFee()/100.0));
			c.setOrderStatus("SUCCESS");
			dataList.add(c);
		}

		String createTime = FSDate.getDateTime();
		String condition = "日切日期[" + settleDateStart + "至" + settleDateEnd + "]";
		String fileName = "本地交易报表_" + settleDateStart + "至" + settleDateEnd;

		Context context = new Context();
		context.putVar("createTime", createTime);
		context.putVar("condition", condition);
		context.putVar("list", dataList);

		String templatePath = TEMPLATE + "local_detail.xlsx";
		String targetPath = REPORT_PATH + fileName + ".xlsx";
		LinkedHashMap<String, Context> sheetNameAndData = new LinkedHashMap<>();
		sheetNameAndData.put("本地交易明细", context);
		String[] templateSheetName = { "sheet1" };

		try {
			FSExcel.exportLargeData(templatePath, targetPath, sheetNameAndData, templateSheetName);
		} catch (Exception e) {
			FSLog.web.info("导出本地交易明细报表发生异常" + e);
		}
		File file = new File(targetPath);
		return file;
	}

	
	
	public File localDetail(String orgCode, String merchCode, String settleDateStart, String settleDateEnd) {
		List<TradeOrder> detailList = TradeOrder.dao.searchReportForMerch(orgCode, merchCode, settleDateStart, settleDateEnd);
		if (detailList.isEmpty()) {
			//HCLog.web.info("没有满足条件的本地交易数据");
			return null;
		}
		DecimalFormat df = new DecimalFormat("0.00");
		List<TradeOrder> dataList = new ArrayList<>(detailList.size());
		for (TradeOrder c : detailList) {
			String merchName = merchMap.get(c.getMerchCode());
			if (StrKit.isBlank(merchName)) {
				Merch m = Merch.dao.selectByMerchCode(c.getMerchCode());
				if (m != null) {
					merchName = m.getName();
					merchMap.put(m.getCode(), m.getName());
				}
			}
			c.put("merchName", merchName);
			c.setPayType(payTypeMap.get(c.getPayType()));
			c.put("amountY", df.format(c.getAmount()/100.0));
			c.put("merchFeeY",df.format(c.getMerchFee()/100.0));
			c.setOrderStatus("SUCCESS");
			dataList.add(c);
		}

		String createTime = FSDate.getDateTime();
		String condition = "日切日期[" + settleDateStart + "至" + settleDateEnd + "]";
		String fileName = "本地交易报表_" + settleDateStart + "至" + settleDateEnd;

		Context context = new Context();
		context.putVar("createTime", createTime);
		context.putVar("condition", condition);
		context.putVar("list", dataList);

		String templatePath = TEMPLATE + "local_detail.xlsx";
		String targetPath = REPORT_PATH + fileName + ".xlsx";
		LinkedHashMap<String, Context> sheetNameAndData = new LinkedHashMap<>();
		sheetNameAndData.put("本地交易明细", context);
		String[] templateSheetName = { "sheet1" };

		try {
			FSExcel.exportLargeData(templatePath, targetPath, sheetNameAndData, templateSheetName);
		} catch (Exception e) {
			FSLog.web.info("导出本地交易明细报表发生异常" + e);
		}
		File file = new File(targetPath);
		return file;
	}

	
	
}
